package hms.payment;

import java.sql.*;

import hms.database.*;

/*Using the DBRowObject class, this class passes data from
 * the HMS database for all the Payment options
 * 
 * @author Edgar Onukwugha*/

public class PaymentMethod extends DBRowObject{

	private int guest_ID;
	private Boolean cash_selected;
	private Boolean credit_selected;
	private Boolean debit_selected;
	private Boolean check_selected;
	
	public PaymentMethod(){
		super();
		guest_ID = -1;
		cash_selected = false;
		credit_selected = false;
		debit_selected = false;
		check_selected = false;
	}
	
	/**
	 * IF supplied, the payment method is automatically mapped to a guest ID.
	 * 
	 * @param guestID
	 */
	public PaymentMethod(int guestID) {
		this();
		guest_ID = guestID;
	}
	
	/////////////////////////////////////////////////
	/////               SETTERS                //////
	/////////////////////////////////////////////////
		
	public void setGuestID(int i){
		guest_ID = i;
		markAsChanged();
	}
	
	public void setCashSelected(Boolean i){
		cash_selected = i;
		markAsChanged();
	}
	
	public void setCreditSelected(Boolean i){
		credit_selected = i;
		markAsChanged();
	}
	
	public void setDebitSelected(Boolean i){
		debit_selected = i;
		markAsChanged();
	}
	
	public void setCheckSelected(Boolean i){
		check_selected = i;
		markAsChanged();
	}
	
	/////////////////////////////////////////////////
	/////               GETTERS                //////
	/////////////////////////////////////////////////
	
	public int getGuestID(){
		return guest_ID;
	}
	
	public Boolean getCashSelected(){
		return cash_selected;
	}
	
	public Boolean getCreditSelected(){
		return credit_selected;
	}
	
	public Boolean getDebitSelected(){
		return debit_selected;
	}
	
	public Boolean getCheckSelected(){
		return check_selected;
	}
	
	@Override
	protected String[] getFieldNames() {
		String[] output = new String[5];
		output[0] = "GUEST_ID";
		output[1] = "CASH_SELECTED";
		output[2] = "CREDIT_SELECTED";
		output[3] = "DEBIT_SELECTED";
		output[4] = "CHECK_SELECTED";
		
		return output;
	}

	@Override
	protected void loadPreparedStatement(PreparedStatement stmt)
			throws SQLException {
		stmt.setInt(1, guest_ID);
		stmt.setBoolean(2, cash_selected);
		stmt.setBoolean(3, credit_selected);
		stmt.setBoolean(4, debit_selected);
		stmt.setBoolean(5, check_selected);
	
	}

	@Override
	protected String getUniqueIdentifierFieldName() {
		// TODO Auto-generated method stub
		return "PAYMENT_METHOD_ID";
	}

	@Override
	protected String getTableName() {
		// TODO Auto-generated method stub
		return "PAYMENT_METHOD";
	}

	@Override
	protected void loadFromDatabase(ResultSet rs) throws SQLException {
		this.guest_ID = rs.getInt("GUEST_ID");
		this.cash_selected = rs.getBoolean("CASH_SELECTED");
		this.credit_selected = rs.getBoolean("CREDIT_SELECTED");
		this.debit_selected = rs.getBoolean("DEBIT_SELECTED");
		this.check_selected = rs.getBoolean("CHECK_SELECTED");
		
	}

	@Override
	protected boolean allowDuplicateRows() {
		// TODO Auto-generated method stub
		return false;
	}

}
